<?php
set_time_limit(0);
include_once("./c/config.php");
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
  

$query=$mysqli->query("SELECT * FROM `ci3` WHERE `miao` = 0 limit 0,500   ");

 
while ($list=$query->fetch_assoc()){
    $id=$list['id'];
    $time=$list['createtime'];
    $openid=$list['openid'];
    $fen=$list['fen'];
    $timeA=strtotime($time);
    
    echo $id,'....',$time,'....',$openid,'....',$fen;
    echo "<br /><br />";
    echo $timeA;
    echo "<br /><br />";
    $queryU=$mysqli->query("SELECT createtime FROM ci3_log where openid='".$openid."' limit 0,1 ");
    if($queryU->num_rows>0){
        $getData=$queryU->fetch_assoc();
        var_dump($getData);
        
        $timeB=strtotime($getData['createtime']);
        
        echo $timeB;
        echo "<br /><br />";
        
        $cha=$timeA - $timeB;
        echo $cha;
     
        echo "<br /><br />";
        
        if ($cha < 0){
            $cha=rand(10,200);
        }
    
    }else{
        $cha=rand(10,200);
    }
    
    if ($fen < 1){
        $cha=rand(1,5);
    }
   
    $m = floor(($cha%(3600*24))%3600/60);
    $s = floor(($cha%(3600*24))%60);
    echo $m,'....',$s;
    
    
    echo "<br /><br />";
    
    
    $miao=$m*60 + $s;
    if ($miao > 900){
        $miao=900;
    }
    
     
    $mysqli->query("update ci3 set miao=".$miao." where id='".$list['id']."' ");
    
    
}
 
